<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/msg/chatRecord.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return'<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>运营管理</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>聊天记录</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

    var has_add = '';
    var has_edit = '';
    var has_delete = '';
</script>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-body">
                <div class="row">
                    <div class="pull-left search col-md-3">
                        <button type="button" class="btn  btn-primary" onclick="showModel()">
                            回复消息
                        </button>
                    </div>
                </div>
                <input id="memberId" name="memberId" value="${memberId}" type="hidden">
                <table id="exampleTable" data-mobile-responsive="true">
                </table>
            </div>
        </div>
    </div>
</div>

<%--  回复消息模态框  --%>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog"
     aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header" style="justify-content: flex-end">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">x 关闭</span></button>
                <%--<h4 class="modal-title" id="exampleModalLabel">关闭</h4>--%>
            </div>
            <div class="modal-body">
                <form id="contentForm">
                    <div class="form-group row">
                        <label class="col-sm-3 col-form-label " style="text-align:center">消息内容:</label>
                        <div class="col-sm-8">
                            <textarea class="form-control" id="content" name="content"
                                      style="width:250px; height:250px"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-success" id="sendMessage">发送</button>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">


    /*  模态框  */
    function showModel(sort, ulId) {
        //  $("#recipient-name").val(sort)
        //  $("#ulId").val(ulId)
        $('#exampleModal').modal('show')

        $("#sendMessage").unbind("click").bind("click", function () {

            var formData = new FormData();
            formData.append("memberId", $("#memberId").val());
            formData.append("content", $("#content").val());
            $.ajax({
                url: prefix + "/sendMessage",
                type: "post",
                data: formData,
                dataType: "json",
                processData: false, // 告诉jQuery不要去处理发送的数据，用于对data参数进行序列化处理 这里必须false
                contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    if (data.status == 200) {
                        parent.layer.msg("操作成功");
                        chatRecord.reLoad();
                        $('#exampleModal').modal('hide')
                    } else {
                        parent.layer.alert(data.message);
                        $('#exampleModal').on('hidden.bs.modal', function () {
                            document.getElementById("contentForm").reset();
                        })
                        //  $('#exampleModal').modal('hide')
                    }

                }
            })
        })


        // $("#giftMember").click(function () {
        //
        //
        // })
    }


    chatRecord.init();
</script>
</body>
</html>